import java.math.BigDecimal;
import java.math.RoundingMode;


public class ModCompareAndRound {

	public static void main(String[] args) {
		double original = 0.5626;
		double tickValue = 0.125;
		double mcr = original;
		
		if (original%tickValue > tickValue/2) {
			mcr = (tickValue)*((int)(original/tickValue))+tickValue;			
		} else if (original%tickValue < tickValue/2) {
			mcr = (tickValue)*((int)(original/tickValue));
		}
		
		mcr = new BigDecimal(tickValue).multiply(new BigDecimal(original).divide(new BigDecimal(tickValue), 0, RoundingMode.HALF_EVEN)).setScale(3, RoundingMode.HALF_EVEN).doubleValue();
		
		System.out.println("Original "+original+" mcr "+new BigDecimal(mcr).doubleValue());

	}

}
